looks very copy/pastey and like bits of these two might be able to be consolidated a bit