Working functional implemetation of doom