initial coding, needs some cleanup