fixed first last calculation