added some constants and combined some variables.