fixed sql stmts, fixed html tmplate and random num gen