another problem solved with terrible programming