Use end value instead of getting length again
Use std namespace