changes after abergeron commented on the code