refcatored to be more OO