added inputs. cleaned up code.