there is a much better way of doing this