Is there any nicer way to write this?