added working return system, improved variable handling