updated with nutki's suggestions