make the solution to #1 a bit less hacky