made the code a bit neater