code update, messy as hell