moved validation to lib