organized functions a little better