Updated solution to check commits in correct order