cleaned code a bit