better way of doing this