updated code based on advices from sensiolabs insight