Fixed script to work with database columns