polishing the code a bit