weight input validation made into function