updated with some of remh's sugesstions