cleaned out and adapted to my needs