Possible quick and dirty implementation, needs testing