created lib file
separated sanitize to own file
various changes