ugly code please do not judge me