Simpler fortran implementation code