cleaned up code (removed templatestuff)