Cleaned structure (but not perfect). Works with or without DB based on variable in order.jsp