cleaned up empty space and fixed loop error