bug fixes, changed function formats