Inital version with some input handling
stil not compatible with broken inputs
(do not use php!)