Re-wrote bucket code with defines