Is there a better way of doing this?