Much saner way of doing this