rough fix, still looking for a more refined one