cleaner, working version